<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>用户信息</title>
	<meta name="keywords" content="">
	<meta name="description" content="">
<style>
	.outimg {
		width: 80px;
		height: 80px;
		margin-left: 10px;
		float: left;
	}
	
	.outimg img {
		width: 80px;
		height: 80px;
	}
	
	.outimg a {
		display: block;
		text-align: center;
		height: 22px;
		line-height: 22px;
	}
</style>
</head>
<div th:include="shared/css"></div>
<div th:include="shared/js"></div>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-content">
						<form id="form" method="get" class="form-horizontal">
							<div class="ibox-title">
								<h5>
									<normal>用户信息</normal>
								</h5>
							</div>
							<div class="ibox-content">
								<!--用户id -->
								<input type="hidden" id="userId" name="userId" th:value="${user.userId}" />
								<div class="form-group">
									<label class="col-sm-1 control-label">用户姓名</label>
									<div class="col-sm-2">
										<input type="text" class="form-control" name="userName"
											   id="userName" th:value="${user.userName}" placeholder="请输入用户姓名">
									</div>
									
									<label class="col-sm-1 control-label">用户手机</label>
									<div class="col-sm-2">
										<input type="text" class="form-control" name="userMobile"
											   id="userMobile" th:value="${user.phoneNum}" placeholder="请输入用户手机">
									</div>
									<!-- <label class="col-sm-1 control-label">公司名</label>
									<div class="col-sm-2">
										<input type="text" class="form-control" name="companyName"
											   id="companyName" th:value="${user.companyName}" placeholder="请输入用户公司">
									</div> -->
								</div>
								<div class="hr-line-dashed"></div>
								<div class="hr-line-dashed" th:style="${user.userId == null} ? 'display: none;'"></div>
								<div class="hr-line-dashed"></div>
								<!-- <div class="form-group">
									<label class="col-sm-1 control-label">是否为管理员</label>
									<div class="col-sm-2">
										<select class="form-control m-b" id="isAdmin" name="isAdmin">
											<option value="0" th:attr="selected=${user.isAdmin == 0} ? 'selected' ">否</option>
											<option value="1" th:attr="selected=${user.isAdmin == 1} ? 'selected' ">是</option>
										</select>
									</div>
								</div> -->

							</div>
							<div class="ibox-content">
								<div class="form-group">
									<div class="col-sm-12" style="text-align: center">
										<input th:if="${user.userId == null}" class="btn btn-primary" type="button" value="提交"  onclick="handleUser('add')">
										<input th:if="${user.userId != null}" class="btn btn-primary" type="button" value="保存"  onclick="handleUser('update')">
									</div>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>

	<script type="text/javascript"  th:inline="javascript">
	//上传文件样式
	$('input[type="file"]').prettyFile();	
	//上传
	function upload(){
		$.ajaxFileUpload({  //Jquery插件上传文件
	        url: '/hs/webutil/uploadImage',
	        secureuri: false,//是否启用安全提交  默认为false
	        fileElementId: "file", //type="file"的id
	        dataType: "json",  //返回值类型
	        success: function (data){
	            if(data.status==10001){//上传成功
	            	$("#userImg").attr("src",data.data[0].imgUrl);
	            	swal("上传成功！");
	            }else{
	            	swal("上传失败。。");
	            }
	
	        },
	    });
	}

		
	function handleUser() {
		if($("#userName").val()==""){
			swal("用户名不能为空");
			return;
		}
		if($("#userMobile").val()==""){
			swal("用户手机不能为空");
			return;
		}
		if(!isPoneAvailable($("#userMobile").val())){
   			swal("非法的手机号");
   			return;
   		}
		var param = {
			"userId":$("#userId").val(),
			"userName":$("#userName").val(),
			"phoneNum":$("#userMobile").val(),
			/* "isAdmin":$("#isAdmin").val() */
		}
		execute("/handlerUser", param);
	}
	function isPoneAvailable(poneInput) {  
		var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/; 
		return myreg.test(poneInput);
    }  	
		
	</script>
</body>

</html>